#pragma once

#include <iostream>
#include <unistd.h>
#include <string>

static const int defaultValue = 0;
static const std::string str = "+-";

// 计算加减法的任务类
class Task
{
private:
    int _x;
    int _y;
    char _op;
    int _result;

public:
    //构造与析构函数
    Task() {}
    Task(int x, int y, char op)
        : _x(x), _y(y), _op(op), _result(defaultValue) {}
    ~Task() {}

    void Run()
    {
        switch (_op)
        {
        case '+':
            _result = _x + _y;
            break;
        case '-':
            _result = _x - _y;
            break;
        default:
            std::cout << "op is error" << std::endl;
            break;
        }
    }
    // 运行任务重载函数
    void operator()()
    {
        Run();
        std::cout << _x << _op << _y << "=" << _result << std::endl;
        sleep(2);
    }
};